<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../../../component/pear/css/pear.css"/>
</head>
<body>
<form class="layui-form" action="" lay-filter="edit">
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label">上传文件</label>
                <div class="layui-input-block">
                    <input type="text" name="commTypeName" lay-verify="title|required" class="layui-input" readonly>
                </div>
            </div>
        </div>
    </div>
</form>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>

<script>
    layui.use(['form', 'jquery', 'dtree', 'easyAdmin'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let easyAdmin = layui.easyAdmin;
        let upload = layui.upload;

        upload.render({
            elem: '#uploadPicture'
            , url: '/sys/file/upload-product' //此处配置你自己的上传接口即可
            , accept: 'images' //图片文件
            , data: {
                id: 1,
                name: 'laker'
            },
            done: function (res) {
                // layer.msg('上传成功');
                $("#commPicUri").attr("src", res.data.filePath);
                $("input[name='commPicId']").val(res.data.fileId);
                console.log(res)
            }, error: function () {
                //请求异常回调
                layer.msg('上传文件失败');
            }
        });

        easyAdmin.http({
            url: '/inv/message/' + id,
            dataType: 'json',
            contentType: 'application/json',
            type: 'get',
            success: function (result) {
                if (result.success) {
                    //表单数据回显
                    form.val("edit", result.data);
                } else {
                    layer.msg(result.msg, {icon: 2, time: 1000});
                }
            }
        });
    })
</script>
<script>
</script>
</body>
</html>
